package com.aaa.dem1102.d02;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Author: whj
 * @Version 1.0
 * @Date: 2022/11/2  15:49
 */
public class Test {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(5);
        for(int i=0;i<5;i++){
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    for(int i=0;i<20;i++) {
                        System.out.println(Thread.currentThread().getName() + "~~~~~~~~~~"+i);
                    }
                }
            });
        }

        //关闭线程池， ---任务没有执行完，就被打断。
        executorService.shutdownNow();
        boolean shutdown = executorService.isShutdown();
        System.out.println("shutdown*****"+shutdown);

        //判断线程池是否终止----里面的任务执行完毕
        boolean b = executorService.isTerminated();
        System.out.println("b*****"+b);
    }
}
